/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

/* Responsive height for new tab */
@media (min-height: 600px) {
    .container {
        height: 90vh;
    }
}

/* Conductor introduction */
.conductor-intro {
    text-align: center;
    animation: fadeIn 1s ease-in;
}

.conductor {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.speech-bubble {
    background: white;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #333;
    position: relative;
    max-width: 300px;
    line-height: 1.4;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-top-color: white;
}

.start-btn {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,107,107,0.3);
    transition: all 0.3s ease;
    font-family: inherit;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255,107,107,0.4);
}

/* Game interface */
.game-interface {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

/* Progress bar */
.progress-container {
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    color: white;
    font-weight: bold;
    margin-top: 5px;
    font-size: 0.9rem;
}

/* Train container */
.train-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.train-engine {
    font-size: 2.5rem;
    animation: chugChug 2s infinite;
}

.carriage {
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-width: 80px;
    text-align: center;
    margin: 5px;
}

.carriage:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.carriage.active {
    background: linear-gradient(135deg, #FFE082, #FFCC02);
    transform: scale(1.05);
}

.carriage.completed {
    background: linear-gradient(135deg, #C8E6C9, #4CAF50);
    animation: glow 1s ease-in-out;
}

.carriage-header {
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.emoji-scene {
    font-size: 1.5rem;
    margin: 5px 0;
    line-height: 1.2;
}

.completion-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.carriage.completed .completion-indicator {
    opacity: 1;
    animation: sparkle 1s ease-in-out;
}

/* Question panel */
.question-panel {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.question-header h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.hint-text {
    color: #FF6B6B;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-bottom: 10px;
}

.hint-text.show {
    opacity: 1;
}

.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.option-btn {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    border: 2px solid transparent;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    color: #333;
    font-family: inherit;
    min-height: 44px; /* Touch-friendly size */
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.option-btn.correct {
    background: linear-gradient(135deg, #C8E6C9, #4CAF50);
    color: white;
    animation: correctPulse 0.6s ease;
}

.option-btn.incorrect {
    background: linear-gradient(135deg, #FFCDD2, #F44336);
    color: white;
    animation: shake 0.5s ease;
}

.scene-display {
    margin-top: 15px;
    padding: 15px;
    background: #F5F5F5;
    border-radius: 15px;
}

.current-emoji {
    font-size: 2rem;
    line-height: 1.3;
}

/* Celebration */
.celebration {
    text-align: center;
    animation: celebrationEntry 1s ease-in;
}

.fireworks {
    font-size: 3rem;
    margin-bottom: 20px;
    animation: fireworksAnimation 2s infinite;
}

.celebration-message {
    font-size: 1.3rem;
    color: #333;
    font-weight: bold;
    margin-bottom: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.restart-btn {
    background: linear-gradient(45deg, #4CAF50, #8BC34A);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
    transition: all 0.3s ease;
    font-family: inherit;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76,175,80,0.4);
}

/* Tooltip */
.tooltip {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 250px;
    line-height: 1.4;
}

.container:hover .tooltip {
    opacity: 1;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes chugChug {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

@keyframes glow {
    0% { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
    50% { box-shadow: 0 6px 20px rgba(76,175,80,0.4); }
    100% { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes celebrationEntry {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fireworksAnimation {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .train-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .carriage {
        min-width: 120px;
    }
    
    .emoji-scene {
        font-size: 1.3rem;
    }
    
    .options-container {
        flex-direction: column;
        align-items: center;
    }
    
    .option-btn {
        width: 100%;
        max-width: 200px;
    }
}